package 连续子数组的最大和;
//有整数负数和零
public class Solution
{
    public int FindGreatestSumOfSubArray(int[] array)
    {
        //判断输入
        //1.举例分析数组规律与2.动态规划，代码思路一致
        if (array==null||array.length==0)
            return 0;

        int currentsum=0;
        int maxsum=Integer.MIN_VALUE;
        for (int i = 0; i < array.length; i++)
        {
            if (currentsum<=0)
                currentsum=array[i];
            else
                currentsum+=array[i];
            if (currentsum>maxsum)
                maxsum=currentsum;
        }
        return maxsum;
    }
}
